using System.Collections.Generic;
using System.IO;

namespace Lottery.Client.SL
{
    public class UserScaleInfos
    {
        public List<UserScaleInfo> m_UserScaleInfos;
        public UserScaleInfos()
        {
            this.m_UserScaleInfos = new List<UserScaleInfo>();
        }
        public void SetData(byte[] datas)
        {
            if (datas == null || datas.Length <= 0)
            {
                return;
            }
            this.m_UserScaleInfos.Clear();
            MemoryStream memoryStream = new MemoryStream(datas);
            BinaryReader binaryReader = new BinaryReader(memoryStream);
            while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
            {
                UserScaleInfo userScaleInfo = new UserScaleInfo();
                userScaleInfo.WinTypeID = binaryReader.ReadInt32();
                userScaleInfo.Scale = binaryReader.ReadDouble();
                userScaleInfo.BackPct = binaryReader.ReadDouble();
                this.m_UserScaleInfos.Add(userScaleInfo);
            }
            binaryReader.Close();
            memoryStream.Close();
        }
        public UserScaleInfo GetUserScaleInfo(int WinTypeID)
        {
            using (List<UserScaleInfo>.Enumerator enumerator = this.m_UserScaleInfos.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    UserScaleInfo current = enumerator.Current;
                    if (current.WinTypeID == WinTypeID)
                    {
                        return current;
                    }
                }
            }
            return null;
        }
    }
}